<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
	</body>
	<script type="text/javascript">
		function loadImage(src){
			return new Promise((resolve, reject)=>{
				//实例化一个Image对象
				let img = new Image()
				//指定src
				img.src = src
				//image对象的onload钩子，加载成功响应
				img.onload = ()=>{
					//成功加载
					resolve(img)
				}
				//image对象的onerror钩子，加载失败响应
				img.onerror = reject
			})
		}
		
		loadImage('./96x96.png').then(res=>{
			//这里res就是promise执行resolve之后，接过来的image对象
			console.log(res)
			//操作image对象
			res.style.width = "110px"
			res.style.border = "solid 2px red"
			//把image对象 添加到body中
			document.body.appendChild(res)
		})
		.catch(err=>{
			
		})
		
		
		
		
	</script>
</html>
